package com.whmskj.xjlhsc.mobie.ProductionManagement.service.imp;

import com.whmskj.xjlhsc.mobie.ProductionManagement.mapper.StrangeFiberDailyMapper;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.YiQianJiReportVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.DifferentFiberRemovalMachineVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.YiQianJiVVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.pojo.vo.YiXianJiVO;
import com.whmskj.xjlhsc.mobie.ProductionManagement.service.IStrangeFiberDailyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

/**
 * @author jiaruchun
 * @date 2025-08-26 09:14
 */

@Service
@Slf4j
public class StrangeFiberDailyServiceImpl implements IStrangeFiberDailyService {

    @Autowired
    private StrangeFiberDailyMapper strangeFiberDailyMapper;

    @Override
    public List<DifferentFiberRemovalMachineVO> getStrangeFiberDailyReport() {
        List<DifferentFiberRemovalMachineVO> strangeFiberDailyReport = strangeFiberDailyMapper.getStrangeFiberDailyReport();
        //为集合每一个元素的name加上“异纤机”
        for (DifferentFiberRemovalMachineVO differentFiberRemovalMachineVO : strangeFiberDailyReport) {
            differentFiberRemovalMachineVO.setName("异纤机"+differentFiberRemovalMachineVO.getName());
        }
        log.info("查询异纤机日报告列表为{}",strangeFiberDailyReport);
        return strangeFiberDailyReport;
    }

    @Override
    public YiQianJiVVO getDataList(String time, Long id) {
        LocalDate localDate = LocalDate.parse(time);
        YiQianJiReportVO yiQianJiReportVOReport = strangeFiberDailyMapper.getYiQianJiReport(localDate, id);
        log.info("异纤机{}的一qianji数据为{}",id, yiQianJiReportVOReport);
        if (yiQianJiReportVOReport != null) {
            YiQianJiVVO yiQianJiVVO = new YiQianJiVVO();
            yiQianJiVVO.setItem00(yiQianJiReportVOReport.getItem00());
            yiQianJiVVO.setItem01(yiQianJiReportVOReport.getItem01());
            yiQianJiVVO.setItem02(yiQianJiReportVOReport.getItem02());
            yiQianJiVVO.setItem03(yiQianJiReportVOReport.getItem03());
            ArrayList<YiXianJiVO> dateList = new ArrayList<>();
            dateList.add(new YiXianJiVO("00:00",yiQianJiReportVOReport.getItem04()));
            dateList.add(new YiXianJiVO("01:00",yiQianJiReportVOReport.getItem05()));
            dateList.add(new YiXianJiVO("02:00",yiQianJiReportVOReport.getItem06()));
            dateList.add(new YiXianJiVO("03:00",yiQianJiReportVOReport.getItem07()));
            dateList.add(new YiXianJiVO("04:00",yiQianJiReportVOReport.getItem08()));
            dateList.add(new YiXianJiVO("05:00",yiQianJiReportVOReport.getItem09()));
            dateList.add(new YiXianJiVO("06:00",yiQianJiReportVOReport.getItem10()));
            dateList.add(new YiXianJiVO("07:00",yiQianJiReportVOReport.getItem11()));
            dateList.add(new YiXianJiVO("08:00",yiQianJiReportVOReport.getItem12()));
            dateList.add(new YiXianJiVO("09:00",yiQianJiReportVOReport.getItem13()));
            dateList.add(new YiXianJiVO("10:00",yiQianJiReportVOReport.getItem14()));
            dateList.add(new YiXianJiVO("11:00",yiQianJiReportVOReport.getItem15()));
            dateList.add(new YiXianJiVO("12:00",yiQianJiReportVOReport.getItem16()));
            dateList.add(new YiXianJiVO("13:00",yiQianJiReportVOReport.getItem17()));
            dateList.add(new YiXianJiVO("14:00",yiQianJiReportVOReport.getItem18()));
            dateList.add(new YiXianJiVO("15:00",yiQianJiReportVOReport.getItem19()));
            dateList.add(new YiXianJiVO("16:00",yiQianJiReportVOReport.getItem20()));
            dateList.add(new YiXianJiVO("17:00",yiQianJiReportVOReport.getItem21()));
            dateList.add(new YiXianJiVO("18:00",yiQianJiReportVOReport.getItem22()));
            dateList.add(new YiXianJiVO("19:00",yiQianJiReportVOReport.getItem23()));
            dateList.add(new YiXianJiVO("20:00",yiQianJiReportVOReport.getItem24()));
            dateList.add(new YiXianJiVO("21:00",yiQianJiReportVOReport.getItem25()));
            dateList.add(new YiXianJiVO("22:00",yiQianJiReportVOReport.getItem26()));
            dateList.add(new YiXianJiVO("23:00",yiQianJiReportVOReport.getItem27()));
            yiQianJiVVO.setDateList(dateList);
            return yiQianJiVVO;
        }else {
            YiQianJiVVO yiQianJiVVO = new YiQianJiVVO();
            yiQianJiVVO.setItem00(0.0f);
            yiQianJiVVO.setItem01(0.0f);
            yiQianJiVVO.setItem02(0.0f);
            yiQianJiVVO.setItem03(0.0f);
            ArrayList<YiXianJiVO> dateList = new ArrayList<>();
            dateList.add(new YiXianJiVO("00:00",0.0f));
            dateList.add(new YiXianJiVO("01:00",0.0f));
            dateList.add(new YiXianJiVO("02:00",0.0f));
            dateList.add(new YiXianJiVO("03:00",0.0f));
            dateList.add(new YiXianJiVO("04:00",0.0f));
            dateList.add(new YiXianJiVO("05:00",0.0f));
            dateList.add(new YiXianJiVO("06:00",0.0f));
            dateList.add(new YiXianJiVO("07:00",0.0f));
            dateList.add(new YiXianJiVO("08:00",0.0f));
            dateList.add(new YiXianJiVO("09:00",0.0f));
            dateList.add(new YiXianJiVO("10:00",0.0f));
            dateList.add(new YiXianJiVO("11:00",0.0f));
            dateList.add(new YiXianJiVO("12:00",0.0f));
            dateList.add(new YiXianJiVO("13:00",0.0f));
            dateList.add(new YiXianJiVO("14:00",0.0f));
            dateList.add(new YiXianJiVO("15:00",0.0f));
            dateList.add(new YiXianJiVO("16:00",0.0f));
            dateList.add(new YiXianJiVO("17:00",0.0f));
            dateList.add(new YiXianJiVO("18:00",0.0f));
            dateList.add(new YiXianJiVO("19:00",0.0f));
            dateList.add(new YiXianJiVO("20:00",0.0f));
            dateList.add(new YiXianJiVO("21:00",0.0f));
            dateList.add(new YiXianJiVO("22:00",0.0f));
            dateList.add(new YiXianJiVO("23:00",0.0f));
            yiQianJiVVO.setDateList(dateList);
            return yiQianJiVVO;
        }
    }
}
